<template>
  <div>
    <div v-for="(article, index) in articles" :key="index" class="article-card">
      <div class="article-cards-item frss">
        <div class="left-card-image-container">
          <img class="left-card-image" :src="cardImage">
        </div>
        <div class="fcss">
          <h4 class="acticle-item-title">{{article.title}}</h4>
          <p class="acticle-item-summary">{{article.summary}}</p>
          <p class="acticle-item-footer">
            <span class="icon"><i class="fa fa-calendar-times-o"></i> {{article.create_time}}</span>
            <span class="icon"><i class="fa fa-eye"></i> {{article.view}}</span>
            <span class="icon"><i class="fa fa-commenting-o"></i> {{article.comment_count}}</span>
            <span class="icon"><i class="fa fa-heart"></i> {{article.like_count}}</span>
          </p>
        </div>
      </div>
    </div>
    <div class="more">
      我想要更多
    </div>
  </div>
</template>

<script>
import { getArticles } from '@/api/article'
import { formatTimeToDate } from '@/utils/time'
export default {
  data () {
    return {
      articles: [],
      cardImage: require('@/common/image/CSSClickEvents.jpg')
    }
  },
  mounted () {
    this.getArticles()
  },
  methods: {
    getArticles () {
      getArticles().then(res => {
        let articles = res.data
        articles.forEach(item => {
          item.create_time = formatTimeToDate(item.create_time)
        })
        this.articles = articles
      })
    }
  }
}
</script>

<style scoped>
.article-card{
  margin-bottom: 10px;
  padding: 10px;
  height: 130px;
  width: auto;
  width: 600px;
  background-color: rgba(255,255,255,0.4);
  box-sizing: border-box;
  overflow: hidden;
  transition: background-color 0.3s;
  cursor: default;
}
.article-card:hover{
  background-color: rgba(0,0,0,0.1);
}
.article-card:hover .left-card-image{
  margin-left: -10px;
}
/*卡片左边*/
.left-card-image-container{
  flex-shrink: 0;
  margin-right: 10px;
  height: 110px;
  width: 175px;
  overflow: hidden;
}
.left-card-image{
  width: 100%;
  transform: scale(1.1);
  transition: margin-left 0.3s;
}
/*卡片右边*/
.acticle-item-title{
  margin-bottom: 5px;
  line-height: 20px;
  font-size: 14px;
  font-weight: bolder;
  transition: padding-left 0.3s;
  cursor: pointer;
}
.acticle-item-title:hover{
  padding-left: 10px;
  text-decoration: underline;
}
.acticle-item-summary{
  flex: 1;
  line-height: 24px;
  font-size: 12px;
  height: 50px;
  color: #555;
  display: -webkit-box;
  text-overflow: ellipsis;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}
.acticle-item-footer{
  font-size: 12px;
  color: #a2a2a2;
}
.acticle-item-footer .icon{
  margin-right: 40px;
}
/* more */
.more{
  margin-top: 10px;
  height: 40px;
  line-height: 40px;
  font-size: 14px;
  text-align: center;
  color: rgba(0,0,0,0.5);
  background-color: rgba(255,255,255,0.5);
  cursor: pointer;
}
</style>
